
const Constant = require("./constant.js");

// 钱包app包名
const airtelAppPckageName = "com.airtel.africa.selfcare";

// 打开 app
const openAirtelApp = () => {
    let pckName = airtelAppPckageName;
    console.log(Constant.UI_SDK_VERSION + "打开: AirtelPay App: ", pckName);

    // com.orange.orangemoneyafrique
    app.launchPackage(pckName)

    console.log(Constant.UI_SDK_VERSION + "等待10秒");
    sleep(10 * 1000);
}

// 退出 app
const closeAirtelApp = () => {
    let pckName = airtelAppPckageName;//app.getPackageName("Airtel");
    //强制停止 com.orange.orangemoneyafrique
    console.log(Constant.UI_SDK_VERSION + "强制停止 AirtelPay app: ", pckName);

    app.openAppSetting(pckName);
    text(app.getAppName(pckName)).waitFor();
    sleep(500);
    click("强行停止")
    console.log(Constant.UI_SDK_VERSION + app.getAppName(pckName) + "应用已被关闭");
    sleep(2 * 1000);
    click("确定");
    sleep(2 * 1000);
    back();
    sleep(5 * 1000);
}

module.exports = {
    airtelAppPckageName: airtelAppPckageName,
    openAirtelApp: openAirtelApp,
    closeAirtelApp: closeAirtelApp
};